using System.ComponentModel.DataAnnotations;
using System.Data.Entity.ModelConfiguration;

namespace ClassLibrary1.Models.Mapping
{
    public class Bs_UserInfoMap : EntityTypeConfiguration<Bs_UserInfo>
    {
        public Bs_UserInfoMap()
        {
            // Primary Key
            this.HasKey(t => t.UId);

            // Properties
            this.Property(t => t.UUserName)
                .HasMaxLength(50);

            this.Property(t => t.UPassword)
                .HasMaxLength(100);

            this.Property(t => t.UTrueName)
                .HasMaxLength(10);

            this.Property(t => t.UMobile)
                .HasMaxLength(20);

            this.Property(t => t.UEmail)
                .HasMaxLength(30);

            this.Property(t => t.UMemo)
                .HasMaxLength(200);

            // Table & Column Mappings
            this.ToTable("Bs_UserInfo");
            this.Property(t => t.UId).HasColumnName("UId");
            this.Property(t => t.UUserName).HasColumnName("UUserName");
            this.Property(t => t.UPassword).HasColumnName("UPassword");
            this.Property(t => t.UTrueName).HasColumnName("UTrueName");
            this.Property(t => t.UDepartID).HasColumnName("UDepartID");
            this.Property(t => t.UMobile).HasColumnName("UMobile");
            this.Property(t => t.UEmail).HasColumnName("UEmail");
            this.Property(t => t.UFlag).HasColumnName("UFlag");
            this.Property(t => t.UMemo).HasColumnName("UMemo");

            // Relationships
            this.HasOptional(t => t.Bs_Department)
                .WithMany(t => t.Bs_UserInfo)
                .HasForeignKey(d => d.UDepartID);

        }
    }
}
